<div ng-controller="dataModelManageController">
    <div class="row" style="position: relative;">
        <div class="col-sm-2" style="width: 20%;position: fixed;top: 65px; bottom: 0;">
            <div class="row">
                <div class="col-sm-12">
                    <button type="button" class="btn btn-primary btn-sm" location-back>返回</button>
                    <div class="pull-right">
                        <div class="btn-group" role="group">
                            <button type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" ng-disabled="!dataModelControl.editable" aria-haspopup="true" aria-expanded="false">
                                工具<span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu dropdown-menu-right">
                                <li ng-repeat="templateStrategy in templateStrategys"><a href="javascript:void(0);" ng-click="run(templateStrategy);">{{templateStrategy.name}}</a></li>
                                <li ng-if="templateStrategys.length" role="separator" class="divider"></li>
                                <li><a href="javascript:void(0);"  ng-click="dataDictionary();">数据字典</a></li>
                                <li><a href="javascript:void(0);"  ng-click="openConsoleModal();">控制台</a></li>
                            </ul>
                        </div>
                        <div class="btn-group" role="group">
                            <button uib-tooltip="请及时保存数据" tooltip-placement="bottom" tooltip-trigger="none" tooltip-is-open="!(!dataModelControl.editable || !dataModelControl.dirtyData.hasDirtyData())"
                                    type="button" ng-click="dataModelControl.saveDirty();" ng-disabled="!dataModelControl.editable || !dataModelControl.dirtyData.hasDirtyData()" class="btn btn-sm btn-warning">
                                保存
                            </button>
                            <button type="button" class="btn btn-sm btn-success dropdown-toggle" ng-disabled="!dataModelControl.editable" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                新建
                            </button>
                            <ul class="dropdown-menu dropdown-menu-right">
                                <li ng-repeat="dynamicModel in dynamicModels | filter:{isRootChild:true}">
                                    <a href="javascript:void(0);" ng-click="dataModelControl.add(dynamicModel);"><span class="glyphicon glyphicon-{{dynamicModel.icon}}"></span> {{dynamicModel.name}}</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row" style="overflow: auto;">
                <div class="col-sm-12 condensed-list" style="width: 20%;position: fixed;top: 100px; bottom: 0;overflow: auto;">
                    <ul ui-sortable="dataModelControl.sortableOptions" ng-model="dataModel.children" style="padding-left: 0;" ng-init="parent=dataModel;" ng-include="'dataModelRecursion'" class="list-group" ng-show="dataModel.children.length"></ul>
                </div>
            </div>
        </div>
        <div class="col-sm-10" style="width: 80%;margin-left: 20%;">
            <uib-tabset ng-if="tabsControl.data.length">
                <uib-tab ng-repeat="dataModel in tabsControl.data" active="dataModel.active" ng-init="tabsControl.initScope(dataModel,this)">
                    <uib-tab-heading><i class="text-info glyphicon glyphicon-{{dataModel.dynamicModel.icon}}"></i> <label>{{dataModel.name}}</label></uib-tab-heading>
                    <br/>
                    <form name="dataModelEditForm" class="form-horizontal" role="form" novalidate>
                        <div class="form-group">
                            <label class="col-sm-1 control-label" for="name"><span class="text-danger">名称</span></label>
                            <div class="col-sm-3">
                                <input id="name" name="name" uib-tooltip="{{getMessage('name',dataModelEditForm.name.$error,validateMessages)}}"
                                       tooltip-trigger="none" tooltip-is-open="dataModelEditForm.name.$invalid && dataModelEditForm.name.$dirty"
                                       ng-model="dataModel.name" type="text" class="form-control input-sm" placeholder="名称" ng-maxlength="32" required/>
                            </div>
                        </div>
                        <div class="form-group" ng-repeat="property in dataModel.dynamicModel.fromGroup">
                            <label class="col-sm-1 control-label" for="${{dataModel.id}}$properties${{property.children.length ? '' : property.name}}"><span ng-class="{'text-danger': property.validator.required}">{{property.children.length ? property.group : property.label}}</span></label>
                            <div ng-if="property.children" class="col-sm-11">
                                <div class="form-inline">
                                    <div class="form-group" ng-repeat="property in property.children" style="margin-left: 0;margin-right: 0;" ng-switch="property.type">
                                        <label for="${{dataModel.id}}$properties${{property.name}}"><span ng-class="{'text-danger': property.validator.required}">{{property.label}}</span></label>
                                        <span ng-switch-when="Boolean" ng-style="{'width':property.viewWidth}" style="display: inline-block;">
                                            <input id="${{dataModel.id}}$properties${{property.name}}" name="$properties${{property.name}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$properties$' + property.name].$error,validateMessageCache[dataModel.dynamicModel.id].propertiesMessages)}}"
                                                   tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$properties${{property.name}}.$invalid && dataModelEditForm.$properties${{property.name}}.$dirty"
                                                   ng-model="dataModel.properties[property.name]" type="checkbox" ng-true-value="true" ng-false-value="false" ng-change="property.cascadeFunction(dataModel.properties)"/>
                                        </span>
                                        <input id="${{dataModel.id}}$properties${{property.name}}"  name="$properties${{property.name}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$properties$' + property.name].$error,validateMessageCache[dataModel.dynamicModel.id].propertiesMessages)}}"
                                               tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$properties${{property.name}}.$invalid && dataModelEditForm.$properties${{property.name}}.$dirty"
                                               ng-switch-when="Long" ng-model="dataModel.properties[property.name]" type="number" class="form-control input-sm" ng-change="property.cascadeFunction(dataModel.properties)"  ng-style="{'width':property.viewWidth}"
                                               min="{{property.validator.min}}" max="{{property.validator.max}}" ng-minlength="property.validator.minlength" ng-maxlength="property.validator.maxlength" ng-pattern="property.validator.pattern" ng-required="property.validator.required"/>
                                        <input id="${{dataModel.id}}$properties${{property.name}}" name="$properties${{property.name}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$properties$' + property.name].$error,validateMessageCache[dataModel.dynamicModel.id].propertiesMessages)}}"
                                               tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$properties${{property.name}}.$invalid && dataModelEditForm.$properties${{property.name}}.$dirty"
                                               ng-switch-when="Double" ng-model="dataModel.properties[property.name]" type="number" class="form-control input-sm" ng-change="property.cascadeFunction(dataModel.properties)" ng-style="{'width':property.viewWidth}"
                                               min="{{property.validator.min}}" max="{{property.validator.max}}" ng-minlength="property.validator.minlength" ng-maxlength="property.validator.maxlength" ng-pattern="property.validator.pattern" ng-required="property.validator.required"/>
                                        <input id="${{dataModel.id}}$properties${{property.name}}" name="$properties${{property.name}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$properties$' + property.name].$error,validateMessageCache[dataModel.dynamicModel.id].propertiesMessages)}}"
                                               tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$properties${{property.name}}.$invalid && dataModelEditForm.$properties${{property.name}}.$dirty"
                                               ng-switch-when="String" ng-model="dataModel.properties[property.name]" type="text" class="form-control input-sm" ng-change="property.cascadeFunction(dataModel.properties)" ng-style="{'width':property.viewWidth}"
                                               ng-minlength="property.validator.minlength" ng-maxlength="property.validator.maxlength" ng-pattern="property.validator.pattern" ng-required="property.validator.required"/>
                                        <input id="${{dataModel.id}}$properties${{property.name}}" name="$properties${{property.name}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$properties$' + property.name].$error,validateMessageCache[dataModel.dynamicModel.id].propertiesMessages)}}"
                                               tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$properties${{property.name}}.$invalid && dataModelEditForm.$properties${{property.name}}.$dirty"
                                               ng-switch-when="Date" ng-model="dataModel.properties[property.name]" type="text" readonly="readonly" class="form-control input-sm" ng-change="property.cascadeFunction(dataModel.properties)" ng-style="{'width':property.viewWidth}"
                                               uib-datepicker-popup="yyyy-MM-dd" is-open="opened" ng-click="opened = !opened" close-text="关闭" current-text="今天"  clear-text="清除"
                                               ng-required="property.validator.required"/>
                                        <select id="${{dataModel.id}}$properties${{property.name}}" name="$properties${{property.name}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$properties$' + property.name].$error,validateMessageCache[dataModel.dynamicModel.id].propertiesMessages)}}"
                                                tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$properties${{property.name}}.$invalid && dataModelEditForm.$properties${{property.name}}.$dirty"
                                                ng-switch-when="Enum" ng-model="dataModel.properties[property.name]" ng-options="option for option in property.optionalValues" class="form-control input-sm" ng-change="property.cascadeFunction(dataModel.properties)" ng-style="{'width':property.viewWidth}"
                                                ng-required="property.validator.required">
                                            <option value="">--选择--</option>
                                        </select>
                                        <input id="${{dataModel.id}}$properties${{property.name}}" name="$properties${{property.name}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$properties$' + property.name].$error,validateMessageCache[dataModel.dynamicModel.id].propertiesMessages)}}"
                                               tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$properties${{property.name}}.$invalid && dataModelEditForm.$properties${{property.name}}.$dirty"
                                               ng-switch-when="Model" ng-model="dataModel.properties[property.name].name" readonly="readonly" type="text" class="form-control input-sm" ng-style="{'width':property.viewWidth}"
                                               ng-change="property.cascadeFunction(dataModel.properties)" ng-click="dataModelPickerModalOpen(dataModel,dataModel.properties,property.name,property.label,dataModelEditForm['$properties$' + property.name]);"
                                               ng-required="property.validator.required"/>
                                        &nbsp;
                                    </div>
                                </div>
                            </div>
                            <div ng-if="!property.children" class="col-sm-11" ng-switch="property.type">
                                <input id="${{dataModel.id}}$properties${{property.name}}" name="$properties${{property.name}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$properties$' + property.name].$error,validateMessageCache[dataModel.dynamicModel.id].propertiesMessages)}}"
                                       tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$properties${{property.name}}.$invalid && dataModelEditForm.$properties${{property.name}}.$dirty"
                                       ng-switch-when="Boolean" ng-model="dataModel.properties[property.name]" type="checkbox" ng-true-value="true" ng-false-value="false" ng-change="property.cascadeFunction(dataModel.properties)"/>
                                <input id="${{dataModel.id}}$properties${{property.name}}" name="$properties${{property.name}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$properties$' + property.name].$error,validateMessageCache[dataModel.dynamicModel.id].propertiesMessages)}}"
                                       tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$properties${{property.name}}.$invalid && dataModelEditForm.$properties${{property.name}}.$dirty"
                                       ng-switch-when="Long" ng-model="dataModel.properties[property.name]" type="number" class="form-control input-sm" ng-change="property.cascadeFunction(dataModel.properties)" ng-style="{'width':property.viewWidth}"
                                       min="{{property.validator.min}}" max="{{property.validator.max}}" ng-minlength="property.validator.minlength" ng-maxlength="property.validator.maxlength" ng-pattern="property.validator.pattern" ng-required="property.validator.required"/>
                                <input id="${{dataModel.id}}$properties${{property.name}}" name="$properties${{property.name}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$properties$' + property.name].$error,validateMessageCache[dataModel.dynamicModel.id].propertiesMessages)}}"
                                       tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$properties${{property.name}}.$invalid && dataModelEditForm.$properties${{property.name}}.$dirty"
                                       ng-switch-when="Double" ng-model="dataModel.properties[property.name]" type="number" class="form-control input-sm" ng-change="property.cascadeFunction(dataModel.properties)" ng-style="{'width':property.viewWidth}"
                                       min="{{property.validator.min}}" max="{{property.validator.max}}" ng-minlength="property.validator.minlength" ng-maxlength="property.validator.maxlength" ng-pattern="property.validator.pattern" ng-required="property.validator.required"/>
                                <input id="${{dataModel.id}}$properties${{property.name}}" name="$properties${{property.name}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$properties$' + property.name].$error,validateMessageCache[dataModel.dynamicModel.id].propertiesMessages)}}"
                                       tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$properties${{property.name}}.$invalid && dataModelEditForm.$properties${{property.name}}.$dirty"
                                       ng-switch-when="String" ng-model="dataModel.properties[property.name]" type="text" class="form-control input-sm" ng-change="property.cascadeFunction(dataModel.properties)" ng-style="{'width':property.viewWidth}"
                                       ng-minlength="property.validator.minlength" ng-maxlength="property.validator.maxlength" ng-pattern="property.validator.pattern" ng-required="property.validator.required"/>
                                <input id="${{dataModel.id}}$properties${{property.name}}" name="$properties${{property.name}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$properties$' + property.name].$error,validateMessageCache[dataModel.dynamicModel.id].propertiesMessages)}}"
                                       tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$properties${{property.name}}.$invalid && dataModelEditForm.$properties${{property.name}}.$dirty"
                                       ng-switch-when="Date" ng-model="dataModel.properties[property.name]" type="text" readonly="readonly" class="form-control input-sm" ng-change="property.cascadeFunction(dataModel.properties)" ng-style="{'width':property.viewWidth}"
                                       uib-datepicker-popup="yyyy-MM-dd" is-open="opened" ng-click="opened = !opened" close-text="关闭" current-text="今天"  clear-text="清除"
                                       ng-required="property.validator.required"/>
                                <select id="${{dataModel.id}}$properties${{property.name}}" name="$properties${{property.name}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$properties$' + property.name].$error,validateMessageCache[dataModel.dynamicModel.id].propertiesMessages)}}"
                                        tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$properties${{property.name}}.$invalid && dataModelEditForm.$properties${{property.name}}.$dirty"
                                        ng-switch-when="Enum" ng-model="dataModel.properties[property.name]" ng-options="option for option in property.optionalValues" class="form-control input-sm" ng-change="property.cascadeFunction(dataModel.properties)" ng-style="{'width':property.viewWidth}"
                                        ng-required="property.validator.required">
                                    <option value="">--选择--</option>
                                </select>
                                <input id="${{dataModel.id}}$properties${{property.name}}" name="$properties${{property.name}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$properties$' + property.name].$error,validateMessageCache[dataModel.dynamicModel.id].propertiesMessages)}}"
                                       tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$properties${{property.name}}.$invalid && dataModelEditForm.$properties${{property.name}}.$dirty"
                                       ng-switch-when="Model" ng-model="dataModel.properties[property.name].name" readonly="readonly" type="text" class="form-control input-sm" ng-style="{'width':property.viewWidth}"
                                       ng-change="property.cascadeFunction(dataModel.properties)" ng-click="dataModelPickerModalOpen(dataModel,dataModel.properties,property.name,property.label,dataModelEditForm['$properties$' + property.name]);"
                                       ng-required="property.validator.required"/>
                            </div>
                        </div>
                        <div class="form-group" ng-if="dataModel.dynamicModel.association.length">
                            <div class="col-sm-12">
                                <table class="table table-condensed table-hover">
                                    <caption>
                                        <div class="btn-group">
                                            <button type="button" class="btn btn-success btn-sm" ng-disabled="!dataModelControl.editable" ng-click="tabsControl.addProperty(dataModel);">添加</button>
                                            <div class="btn-group">
                                                <button type="button" class="btn btn-success btn-sm dropdown-toggle" ng-disabled="!dataModelControl.editable" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                    <span class="glyphicon glyphicon-plus"></span>
                                                </button>
                                                <ul class="dropdown-menu">
                                                    <li><a href="javascript:void(0)" ng-click="tabsControl.addMultiProperty(dataModel,5);">添加5条</a></li>
                                                    <li><a href="javascript:void(0)" ng-click="tabsControl.addMultiProperty(dataModel,10);">添加10条</a></li>
                                                </ul>
                                            </div>
                                            <div class="btn-group">
                                                <button type="button" class="btn btn-success btn-sm dropdown-toggle" ng-disabled="!dataModelControl.editable || !dataModel.dynamicModel.predefinedAssociation.length" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                    <span class="glyphicon glyphicon-pushpin"></span>
                                                </button>
                                                <ul class="dropdown-menu">
                                                    <li><a href="javascript:void(0)" ng-click="tabsControl.addPredefinedProperty(dataModel);">快捷添加</a></li>
                                                    <li><a href="javascript:void(0)" ng-click="tabsControl.predefinedPropertySetModalOpen(dataModel);">快捷设置</a></li>
                                                </ul>
                                            </div>
                                        </div>
                                        <div class="btn-group" role="group">
                                            <button ng-if="!dataModel.$copy" type="button" class="btn btn-sm btn-success" ng-disabled="!dataModelControl.editable || !dataModel.association.length" ng-click="tabsControl.copyPropertyBegin(dataModel);">复制</button>
                                            <button ng-if="dataModel.$copy" type="button" class="btn btn-sm btn-warning" ng-disabled="!dataModelControl.editable" ng-click="tabsControl.copyPropertyCancel(dataModel);">取消</button>
                                            <button ng-if="dataModel.$copy" type="button" class="btn btn-sm btn-primary" ng-disabled="!dataModelControl.editable" ng-click="tabsControl.copyProperty(dataModel);">确定</button>
                                            <button ng-if="!dataModel.$copy" type="button" class="btn btn-success btn-sm" ng-disabled="dataModel.$copy || !dataModelControl.editable || !tabsControl.hasClipboard(dataModel)" ng-click="tabsControl.pasteProperty(dataModel);">粘贴</button>
                                        </div>
                                        <div class="btn-group" role="group">
                                            <button type="button" class="btn btn-info btn-sm" ng-if="dataModel.dynamicModel.hasHideCols" ng-disabled="!dataModelControl.editable" ng-click="tabsControl.showOrHideCols(dataModel);">{{(dataModel.dynamicModel.$hideCols == undefined || dataModel.dynamicModel.$hideCols) ? "显示": "隐藏"}}列</button>
                                            <button type="button" class="btn btn-info btn-sm dropdown-toggle" ng-if="dataModel.dynamicModel.hasHideCols" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                <span class="caret"></span>
                                            </button>
                                            <ul class="dropdown-menu dropdown-menu-right">
                                                <li ng-repeat="property in dataModel.dynamicModel.association | filter:{canHide:true}">
                                                    <a href="javascript:void(0);"><input type="checkbox" ng-click="property.$hide=!property.$hide;tabsControl.resetHead(dataModel)" ng-checked="!property.$hide"/> {{property.group ? property.group : ""}} {{property.group ? "-" : ""}} {{property.label}}</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </caption>
                                    <thead>
                                    <tr class="active" ng-if="dataModel.dynamicModel.tableHead.heads.length">
                                        <th width="30" rowspan="2" ng-click="dataModel.$copy && dataModelControl.copyAll(dataModel);"><input ng-if="dataModel.$copy" type="checkbox" ng-checked="dataModel.$copyAll"/><span ng-if="!dataModel.$copy">#</span></th>
                                        <th ng-show="!property.$hide" width="{{property.span ? '' : property.viewWidth}}" ng-repeat="property in dataModel.dynamicModel.tableHead.groupHeads" rowspan="{{property.span ? '' : 2}}" colspan="{{!property.span ? '' : property.span}}">
                                            <span ng-class="{'text-danger': property.validator.required, 'hide-col':property.canHide}">{{property.span ? property.group : property.label}}</span>
                                        </th>
                                        <th rowspan="2" style="min-width: 45px;">操作</th>
                                    </tr>
                                    <tr class="active" ng-if="dataModel.dynamicModel.tableHead.heads.length">
                                        <th ng-show="!property.$hide" width="{{property.viewWidth}}" ng-repeat="property in dataModel.dynamicModel.tableHead.heads">
                                            <span ng-class="{'text-danger': property.validator.required, 'hide-col':property.canHide}">{{property.label}}</span>
                                        </th>
                                    </tr>
                                    <tr class="active" ng-if="!dataModel.dynamicModel.tableHead.heads.length">
                                        <th width="30" ng-click="dataModel.$copy && dataModelControl.copyAll(dataModel);"><input ng-if="dataModel.$copy" type="checkbox" ng-checked="dataModel.$copyAll"/><span ng-if="!dataModel.$copy">#</span></th>
                                        <th ng-show="!property.$hide" width="{{property.viewWidth}}" ng-repeat="property in dataModel.dynamicModel.association">
                                            <span ng-class="{'text-danger': property.validator.required, 'hide-col':property.canHide}">{{property.label}}</span>
                                        </th>
                                        <th style="min-width: 45px;">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody ui-sortable="sortableOptions" ng-model="dataModel.association">
                                    <tr ng-repeat="propertyValue in dataModel.association" ng-class="{'warning':propertyValue.$copy}">
                                        <th ng-click="dataModel.$copy && (propertyValue.$copy = !propertyValue.$copy)"><input ng-if="dataModel.$copy" type="checkbox" ng-checked="propertyValue.$copy"/><span ng-if="!dataModel.$copy">{{$index + 1}}</span></th>
                                        <td ng-show="!property.$hide" ng-repeat="property in dataModel.dynamicModel.association" ng-switch="property.type" ng-init="propertyValue.__hashKey = hashKey(propertyValue)">
                                            <input name="$association${{property.name + propertyValue.__hashKey}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$association$' + property.name + propertyValue.__hashKey].$error,validateMessageCache[dataModel.dynamicModel.id].associationMessages)}}"
                                                   tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$association${{property.name + propertyValue.__hashKey}}.$invalid && dataModelEditForm.$association${{property.name + propertyValue.__hashKey}}.$dirty"
                                                   ng-switch-when="Boolean" ng-model="propertyValue[property.name]" type="checkbox" ng-true-value="true" ng-false-value="false" ng-change="property.cascadeFunction(propertyValue)"/>
                                            <input name="$association${{property.name + propertyValue.__hashKey}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$association$' + property.name + propertyValue.__hashKey].$error,validateMessageCache[dataModel.dynamicModel.id].associationMessages)}}"
                                                   tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$association${{property.name + propertyValue.__hashKey}}.$invalid && dataModelEditForm.$association${{property.name + propertyValue.__hashKey}}.$dirty"
                                                   ng-switch-when="Long" ng-model="propertyValue[property.name]" type="number" class="form-control input-sm" ng-change="property.cascadeFunction(propertyValue)"
                                                   min="{{property.validator.min}}" max="{{property.validator.max}}" ng-minlength="property.validator.minlength" ng-maxlength="property.validator.maxlength" ng-pattern="property.validator.pattern" ng-required="property.validator.required"/>
                                            <input name="$association${{property.name + propertyValue.__hashKey}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$association$' + property.name + propertyValue.__hashKey].$error,validateMessageCache[dataModel.dynamicModel.id].associationMessages)}}"
                                                   tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$association${{property.name + propertyValue.__hashKey}}.$invalid && dataModelEditForm.$association${{property.name + propertyValue.__hashKey}}.$dirty"
                                                   ng-switch-when="Double" ng-model="propertyValue[property.name]" type="number" class="form-control input-sm" ng-change="property.cascadeFunction(propertyValue)"
                                                   min="{{property.validator.min}}" max="{{property.validator.max}}" ng-minlength="property.validator.minlength" ng-maxlength="property.validator.maxlength" ng-pattern="property.validator.pattern" ng-required="property.validator.required"/>
                                            <input name="$association${{property.name + propertyValue.__hashKey}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$association$' + property.name + propertyValue.__hashKey].$error,validateMessageCache[dataModel.dynamicModel.id].associationMessages)}}"
                                                   tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$association${{property.name + propertyValue.__hashKey}}.$invalid && dataModelEditForm.$association${{property.name + propertyValue.__hashKey}}.$dirty"
                                                   ng-switch-when="String" ng-model="propertyValue[property.name]" type="text" class="form-control input-sm" ng-change="property.cascadeFunction(propertyValue)"
                                                   ng-minlength="property.validator.minlength" ng-maxlength="property.validator.maxlength" ng-pattern="property.validator.pattern" ng-required="property.validator.required"/>
                                            <input name="$association${{property.name + propertyValue.__hashKey}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$association$' + property.name + propertyValue.__hashKey].$error,validateMessageCache[dataModel.dynamicModel.id].associationMessages)}}"
                                                   tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$association${{property.name + propertyValue.__hashKey}}.$invalid && dataModelEditForm.$association${{property.name + propertyValue.__hashKey}}.$dirty"
                                                   ng-switch-when="Date" ng-model="propertyValue[property.name]" type="text" readonly="readonly" class="form-control input-sm" ng-change="property.cascadeFunction(propertyValue)"
                                                   uib-datepicker-popup="yyyy-MM-dd" is-open="opened" ng-click="opened = !opened" close-text="关闭" current-text="今天"  clear-text="清除"
                                                   ng-required="property.validator.required"/>
                                            <select name="$association${{property.name + propertyValue.__hashKey}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$association$' + property.name + propertyValue.__hashKey].$error,validateMessageCache[dataModel.dynamicModel.id].associationMessages)}}"
                                                    tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$association${{property.name + propertyValue.__hashKey}}.$invalid && dataModelEditForm.$association${{property.name + propertyValue.__hashKey}}.$dirty"
                                                    ng-switch-when="Enum" ng-model="propertyValue[property.name]" ng-options="option for option in property.optionalValues" class="form-control input-sm" ng-change="property.cascadeFunction(propertyValue)"
                                                    ng-required="property.validator.required">
                                                <option value="">--选择--</option>
                                            </select>
                                            <input name="$association${{property.name + propertyValue.__hashKey}}" uib-tooltip="{{getMessage(property.name,dataModelEditForm['$association$' + property.name + propertyValue.__hashKey].$error,validateMessageCache[dataModel.dynamicModel.id].associationMessages)}}"
                                                   tooltip-trigger="none" tooltip-is-open="dataModelEditForm.$association${{property.name + propertyValue.__hashKey}}.$invalid && dataModelEditForm.$association${{property.name + propertyValue.__hashKey}}.$dirty"
                                                   ng-switch-when="Model" ng-model="propertyValue[property.name].name" readonly="readonly" type="text" class="form-control input-sm" ng-change="property.cascadeFunction(propertyValue)" ng-click="dataModelPickerModalOpen(dataModel,propertyValue,property.name,property.label,dataModelEditForm['$association$' + property.name + propertyValue.__hashKey]);"
                                                   ng-required="property.validator.required"/>
                                        </td>
                                        <td>
                                            <div class="btn-group">
                                                <button type="button" class="btn btn-danger btn-sm" ng-disabled="!dataModelControl.editable" ng-click="tabsControl.removeProperty(dataModel, $index)"><span class="glyphicon glyphicon-remove"></span></button>
                                            </div>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </form>
                </uib-tab>
            </uib-tabset>
        </div>
    </div>
</div>
<!-- 控制台对话框 -->
<script id="dataModel/console.html" type="text/ng-template" >
    <div class="modal-header">
        <h3 class="modal-title">控制台 {{runningText}}</h3>
    </div>
    <div class="modal-body">
        <ul class="list-group" ng-repeat="result in runResults track by $index" ng-switch="result.type">
            <li class="list-group-item" ng-switch-when="url"><a ng-click="download(result.url)" href="javascript:void(0)"><i class="glyphicon glyphicon-cloud-download"></i> 点击下载 <span class="text-info">{{result.fileName}}</span></a></li>
            <li class="list-group-item list-group-item-danger" ng-switch-when="error">
                <i class="glyphicon glyphicon-plus" ng-class="result.$closed ?'glyphicon-plus' : 'glyphicon-minus'" ng-click="result.$closed = !result.$closed;"></i>
                <label>异常信息</label>
                <ul class="list-group" ng-repeat="message in result.messages track by $index" ng-show="!result.$closed">
                    <li class="list-group-item">{{message}}</li>
                </ul>
            </li>
        </ul>
    </div>
    <div class="modal-footer">
        <button class="btn btn-sm btn-warning" type="button" ng-click="clear()">清除</button>
        <button class="btn btn-sm btn-primary" type="button" ng-click="confirm()">关闭</button>
    </div>
</script>
<!-- 生成数据导航使用的递归模板 -->
<script id="dataModelRecursion" type="text/ng-template">
    <li class="list-group-item" ng-repeat="child in parent.children" ng-init="p=parent;">
        <i class="glyphicon glyphicon-plus" ng-class="child.children.length ? (child.$expend ? 'glyphicon-minus' : 'glyphicon-plus') : 'glyphicon-leaf'" ng-click="child.$expend =! child.$expend;"></i>
        <label style="margin-right: 5px;">{{$index + 1}}</label>
        <span class="text-info glyphicon glyphicon-{{child.dynamicModel.icon}}"></span>
        <label ng-dblclick="dataModelControl.view(child);">{{child.name}}</label>
        <div class="btn-group pull-right">
            <button type="button" class="btn btn-danger btn-xs" ng-disabled="!dataModelControl.editable" ng-click="dataModelControl.delete(p, $index, child);">
                <span class="glyphicon glyphicon-remove"></span>
            </button>
            <div class="btn-group">
                <button ng-if="child.dynamicModel.children.length" type="button" class="btn btn-success dropdown-toggle btn-xs" ng-disabled="!dataModelControl.editable" data-toggle="dropdown">
                    <span class="glyphicon glyphicon-plus"></span>
                </button>
                <ul ng-if="child.dynamicModel.children.length" class="dropdown-menu dropdown-menu-right" role="menu">
                    <li ng-repeat="dynamicModel in child.dynamicModel.children">
                        <a href="javascript:void(0);" ng-click="dataModelControl.add(dynamicModel, child);">
                            <span class="glyphicon glyphicon-{{dynamicModel.icon}}"></span> {{dynamicModel.name}}
                        </a>
                    </li>
                </ul>
            </div>
        </div>
        <ul ui-sortable="dataModelControl.sortableOptions" ng-model="child.children" class="list-group" ng-include="'dataModelRecursion'" ng-show="child.$expend && child.children.length" ng-init="parent=child;"></ul>
    </li>
</script>
<!-- 数据模型选择对话框 -->
<script id="dataModel/dataModelPicker.html" type="text/ng-template" >
    <div class="modal-header">
        <h3 class="modal-title">{{title}}</h3>
    </div>
    <div class="modal-body condensed-list">
        <div style="padding-left: 0px;" ng-init="parent=dataModel;" ng-include="'dataModelPickerRecursion'" class="list-group" ng-show="dataModel.children.length"></div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-sm btn-danger" type="button" ng-click="clear()">清除</button>
        <button class="btn btn-sm btn-primary" type="button" ng-click="confirm()">关闭</button>
    </div>
</script>
<!-- 数据模型选择对话框使用的递归模板 -->
<script id="dataModelPickerRecursion" type="text/ng-template">
    <a href="javascript:void(0)" class="list-group-item" ng-repeat="child in parent.children" ng-init="p=parent;">
        <i class="glyphicon glyphicon-plus" ng-class="child.children.length ? (child.$$expend ? 'glyphicon-minus' : 'glyphicon-plus') : 'glyphicon-leaf'" ng-click="child.$$expend =! child.$$expend;"></i>
        <label style="margin-right: 5px;">{{$index + 1}}</label>
        <span class="glyphicon glyphicon-{{child.dynamicModel.icon}}"></span>
        <label ng-dblclick="select(child);">{{child.name}}</label>
        <div class="list-group" ng-include="'dataModelPickerRecursion'" ng-show="child.$$expend && child.children.length" ng-init="parent=child;"></div>
    </a>
</script>
<!-- 生成文件之前询问对话框 -->
<script id="dataModel/dataModelRun.html" type="text/ng-template" >
    <div class="modal-header">
        <h3 class="modal-title">{{title}}</h3>
    </div>
    <div class="modal-body condensed-list">
        <div style="padding-left: 0px;" ng-init="parent=dataModel;" ng-include="'dataModelRunRecursion'" class="list-group" ng-show="dataModel.children.length"></div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-sm btn-warning" type="button" ng-click="cancel()">取消</button>
        <button class="btn btn-sm btn-success" type="button" ng-click="checkAll()"><span class="glyphicon" ng-class="{'glyphicon-unchecked':!$checkAll,'glyphicon-check':$checkAll}"></span> 全选</button>
        <button class="btn btn-sm btn-primary" type="button" ng-click="confirm()">确定</button>
    </div>
</script>
<!-- 生成文件之前询问对话框使用的递归模板 -->
<script id="dataModelRunRecursion" type="text/ng-template">
    <a href="javascript:void(0)" class="list-group-item" ng-repeat="child in parent.children" ng-init="p=parent;">
        <input type="checkbox" ng-model="child.$runChecked"/>
        <i class="glyphicon glyphicon-plus" ng-class="child.children.length ? (child.$runExpend ? 'glyphicon-minus' : 'glyphicon-plus') : 'glyphicon-leaf'" ng-click="child.$runExpend =! child.$runExpend;"></i>
        <label style="margin-right: 5px;">{{$index + 1}}</label>
        <span class="glyphicon glyphicon-{{child.dynamicModel.icon}}"></span>
        <label>{{child.name}}</label>
        <div class="list-group" ng-include="'dataModelRunRecursion'" ng-show="child.$runExpend && child.children.length" ng-init="parent=child;"></div>
    </a>
</script>
<!-- 生成数据字典之前询问对话框 -->
<script id="dataModel/dataModelDataDictionary.html" type="text/ng-template">
    <div class="modal-header">
        <h3 class="modal-title">数据字典</h3>
    </div>
    <div class="modal-body condensed-list">
        <div style="padding-left: 0px;" ng-init="parent=dataModel;" ng-include="'dataModelDataDictionaryRecursion'" class="list-group" ng-show="dataModel.children.length"></div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-sm btn-warning" type="button" ng-click="cancel()">取消</button>
        <button class="btn btn-sm btn-success" type="button" ng-click="checkAll()"><span class="glyphicon" ng-class="{'glyphicon-unchecked':!$checkAll,'glyphicon-check':$checkAll}"></span> 全选</button>
        <button class="btn btn-sm btn-primary" type="button" ng-click="confirm()">确定</button>
    </div>
</script>
<!-- 生成数据字典之前询问对话框使用的递归模板 -->
<script id="dataModelDataDictionaryRecursion" type="text/ng-template">
    <a href="javascript:void(0)" class="list-group-item" ng-repeat="child in parent.children" ng-init="p=parent;">
        <input type="checkbox" ng-model="child.$dataDictionaryChecked"/>
        <i class="glyphicon glyphicon-plus" ng-class="child.children.length ? (child.$dataDictionaryExpend ? 'glyphicon-minus' : 'glyphicon-plus') : 'glyphicon-leaf'" ng-click="child.$dataDictionaryExpend =! child.$dataDictionaryExpend;"></i>
        <label style="margin-right: 5px;">{{$index + 1}}</label>
        <span class="glyphicon glyphicon-{{child.dynamicModel.icon}}"></span>
        <label>{{child.name}}</label>
        <div class="list-group" ng-include="'dataModelDataDictionaryRecursion'" ng-show="child.$dataDictionaryExpend && child.children.length" ng-init="parent=child;"></div>
    </a>
</script>
<!-- 快捷添加设置对话框 -->
<script id="dataModel/predefinedPropertySet.html" type="text/ng-template">
    <div class="modal-header">
        <h3 class="modal-title">{{title}}</h3>
    </div>
    <div class="modal-body">
        <table class="table table-condensed table-hover">
            <thead>
            <tr class="active" ng-if="tableHead.heads.length">
                <th width="30" rowspan="2">#</th>
                <th ng-show="!property.$hide" width="{{property.span ? '' : property.viewWidth}}" ng-repeat="property in tableHead.groupHeads"
                    rowspan="{{property.span ? '' : 2}}" colspan="{{!property.span ? '' : property.span}}">
                    {{property.span ? property.group : property.label}}
                </th>
                <th rowspan="2">&nbsp;</th>
            </tr>
            <tr class="active" ng-if="tableHead.heads.length">
                <th ng-show="!property.$hide" width="{{property.viewWidth}}" ng-repeat="property in tableHead.heads" >{{property.label}}</th>
            </tr>
            <tr class="active" ng-if="!tableHead.heads.length">
                <th width="30">#</th>
                <th ng-show="!property.$hide" width="{{property.viewWidth}}" ng-repeat="property in dynamicModel.association">{{property.label}}</th>
                <th>&nbsp;</th>
            </tr>
            </thead>
            <tbody >
            <tr ng-repeat="propertyValue in dynamicModel.predefinedAssociation track by $index">
                <th><input type="checkbox" ng-model="propertyValue.$check" ng-checked="propertyValue.$check"/></th>
                <td ng-show="!property.$hide" ng-repeat="property in dynamicModel.association" ng-switch="property.type">
                    <span ng-switch-when="Boolean"><input onclick="return false;" type="checkbox" ng-checked="propertyValue[property.name]"/></span>
                    <span ng-switch-when="Long">{{propertyValue[property.name]}}</span>
                    <span ng-switch-when="Double">{{propertyValue[property.name]}}</span>
                    <span ng-switch-when="String">{{propertyValue[property.name]}}</span>
                    <span ng-switch-when="Date">{{propertyValue[property.name] | date : 'yyyy-MM-dd'}}</span>
                    <span ng-switch-when="Enum">{{propertyValue[property.name]}}</span>
                    <span ng-switch-when="Model">{{propertyValue[property.name]}}</span>
                </td>
                <td>&nbsp;</td>
            </tr>
            </tbody>
        </table>
    </div>
    <div class="modal-footer">
        <button class="btn btn-sm btn-primary" type="button" ng-click="confirm()">确定</button>
    </div>
</script>
